<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-resourcesType-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">资源名称：</label>
            <div class="col-sm-8">
                <input id="name" name="name" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">资源类型：</label>
            <div class="col-sm-8">
                <input id="type" name="type" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">类型排序：</label>
            <div class="col-sm-8">
                <input id="typeSort" name="typeSort" class="form-control" type="number">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">

                <textarea id="remarks" name="remarks" class="form-control"></textarea>
            </div>
        </div>

    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/resourcesType"
    $("#form-resourcesType-add").validate({
        rules: {
            typeSort: {
                required: true,
            },
            name: {
                required: true,
            },
            type: {
                required: true,
                minlength: 3,
                remote: {
                    url: prefix + "/checkTypeUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        name: function () {
                            return $.common.trim($("#type").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
        },
        messages: {
            "type": {
                remote: "该资源类型已经存在"
            }
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-resourcesType-add').serialize());
        }
    }
</script>
</body>
</html>
